package com.worthtech.billportal.xml;

import org.jdom.*;
import org.jdom.output.*;


/**
 * <p>
 * Title: yangyang ServiceCenter
 * </p>
 * 
 * <p>
 * Description: ServiceCenter
 * </p>
 * 
 * <p>
 * Copyright: Copyright (c) 2006
 * </p>
 * 
 * <p>
 * Company: cardinfo
 * </p>
 * 
 * @author yangyang
 * @version 2.21
 */
public class AjaxMessagesXML {
	Element rootElement;

	private Document messagesDocument;

	private XMLOutputter xmlo;

	public AjaxMessagesXML() {
		rootElement = new Element("messages");
		messagesDocument = new Document(rootElement);
		Format format = Format.getPrettyFormat();
		format.setOmitDeclaration(true);
		xmlo = new XMLOutputter(format);
	}

	public void setMessage(String codeid, String message) {
		rootElement.addContent(new Element("codeid").addContent(codeid));
		rootElement.addContent(new Element("message").addContent(new CDATA(message)));
		rootElement.addContent(new Element("text").addContent(new CDATA("")));
	}

	public void setMessage(String codeid, String message, String text) {
		rootElement.addContent(new Element("codeid").addContent(codeid));
		rootElement.addContent(new Element("message").addContent(new CDATA(
				message)));
		rootElement.addContent(new Element("text").addContent(new CDATA(text)));
	}

	public Document getMessagesDocument() {
		return messagesDocument;
	}

	public XMLOutputter getXmlo() {
		return xmlo;
	}

	public void setMessagesDocument(Document messagesDocument) {
		this.messagesDocument = messagesDocument;
	}

	public void setXmlo(XMLOutputter xmlo) {
		this.xmlo = xmlo;
	}
}
